﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

public partial class MyHomeEventBaoMing : System.Web.UI.PageEx
{
    private DataSet ds = null;
    private int iPageCount = 0;
    private int iRecordCount = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string strResult = string.Empty;
            if (!DalEx.DbUserDalEx.CheckUserLogin(UserType, UserId, ref strResult))
            {
                MessageBox(strResult, "UserLogin.aspx");
                return;
            }
            string strLink = "<li><a href=\"{0}\" class=\"{2}\">{1}</a></li>";
            StringBuilder sbMenuLinks = new StringBuilder();
            if (UserType == 1 && UserId > 0)
            {
                sbMenuLinks.Append(string.Format(strLink, new object[] { "MemberCenter.aspx", "会员中心", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "UserInfos.aspx", "我的资料", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "ModifyPwd.aspx", "修改密码", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "MyBaoMing.aspx", "我的报名表", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "MyYiGongBaoMing.aspx", "义工报名表", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "MyHomeEventBaoMing.aspx", "家园活动报名表", "on" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "Logout.aspx", "退出系统", "" }));
            }
            else
            {
                sbMenuLinks.Append(string.Format(strLink, new object[] { "#", "会员中心", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "#", "我的资料", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "#", "修改密码", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "#", "我的报名表", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "#", "义工报名表", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "#", "家园活动报名表", "" }));
                sbMenuLinks.Append(string.Format(strLink, new object[] { "#", "退出系统", "" }));
            }
            litMenuLinks.Text = sbMenuLinks.ToString();

            DataBinds();
        }
    }
    private void DataBinds()
    {
        string strQuery = " and UserID='" + UserId + "'";
        ds = WebBase.Comm.SelectByPage("BaoMing3 ", "*", "Id", strQuery, anpProduct.PageSize, anpProduct.CurrentPageIndex, "AddTime", 1, out iPageCount, out iRecordCount);
        anpProduct.RecordCount = iRecordCount;
        rptDataList.DataSource = ds;
        rptDataList.DataBind();
    }
    protected void rptDataList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            Label lblNo = (Label)e.Item.FindControl("lblNo");
            lblNo.Text = Convert.ToString(anpProduct.PageSize * (anpProduct.CurrentPageIndex - 1) + e.Item.ItemIndex + 1);
        }
    }
    protected void anpProduct_PageChanged(object sender, EventArgs e)
    {
        DataBinds();
    }
    #region 属性转化
    protected string GetSex(object objValue)
    {
        int iValue = Convert.ToInt32(objValue);
        return iValue == 1 ? "男" : "女";
    }
    protected string GetStatus(object objValue)
    {
        string strResult = string.Empty;
        int iValue = Convert.ToInt32(objValue);
        switch (iValue)
        {
            case 0:
                strResult = "未处理";
                break;
            case 1:
                strResult = "已查看";
                break;
            case 2:
                strResult = "已录取";
                break;
            case 3:
                strResult = "未录取";
                break;
        }
        return strResult;
    }
    protected string GetClassType(object objValue)
    {
        string strResult = string.Empty;
        int iValue = Convert.ToInt32(objValue);
        switch (iValue)
        {
            case 0:
                strResult = "小班";
                break;
            case 1:
                strResult = "中班";
                break;
            case 2:
                strResult = "大班";
                break;
            case 3:
                strResult = "大大班";
                break;
        }
        return strResult;
    }
    protected string GetTel(object objValue1, object objValue2)
    {
        string strResult = string.Empty;
        string strValue1 = Convert.ToString(objValue1);
        string strValue2 = Convert.ToString(objValue2);
        strResult += strValue1;
        if (!string.IsNullOrEmpty(strValue2))
            strResult += "<br />" + strValue2;
        return strResult;
    }
    #endregion
}
